﻿using System;
using Jink.Core.Json.Values;
using Jink.Core.Converters;

namespace Jink.Core.Json
{
    // todo. also support circular references

    public static class JsonSerializer
    {
        public static JsonValue ToJson(this Object obj, params Object[] ctx)
        {
            return obj == null ? null : obj.ToJson(obj.GetType(), ctx);
        }

        public static JsonValue ToJson(this Object obj, Type t, params Object[] ctx)
        {
            return (JsonValue)obj.Convert(t, typeof(JsonValue), ctx);
        }
    }
}
